<?php
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu();
$op = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
load()->func('tpl');
$pageindex = max(1, intval($_GPC['page']));
$pagesize=10;

   	$where=' WHERE  a.uniacid=:uniacid  ';
    $data[':uniacid']=$_W['uniacid'];
    if(isset($_GPC['keywords'])){
        $where.="  and (b.cusname LIKE  concat('%', :name,'%') or b.username LIKE  concat('%', :name,'%') or b.phone LIKE  concat('%', :name,'%'))";
        $data[':name']=$_GPC['keywords']; 
    }
    $sql="SELECT a.*,b.cusname,b.username,b.phone FROM ".tablename('zh_gjw_reputationrecord')  .  " a"  . " left join " . tablename("zh_gjw_cusmanage") . " b on a.openid=b.openid".$where." ORDER BY a.timesjc desc";
    $total=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('zh_gjw_reputationrecord')  .  " a"  . " left join " . tablename("zh_gjw_cusmanage") . " b on a.openid=b.openid".$where." ORDER BY a.timesjc desc",$data);

$select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
$registers=pdo_fetchall($select_sql,$data);
$pager = pagination($total, $pageindex, $pagesize);




if($op=='delete'){
 	 
    $res=pdo_delete('zh_gjw_reputationrecord',array('id'=>$_GPC['id']));
    if($res){
      message('删除成功',$this->createWebUrl('reputationrecords',array()),'success');
    }else{
      message('删除失败','','error');
    }
}



include $this->template('web/reputationrecords');